﻿set_project("ringbuffer")

set_warnings("all", "error")

set_xmakever("2.8.1")
set_version("0.0.1", {build = "%Y%m%d"})

stdc = "c99"
stdcpp = "c++11"
set_languages(stdc, stdcpp)

add_rules("mode.debug", "mode.release")

set_defaultmode("debug")

option("has_libpthread", function()
    add_links("pthread")
    after_check(function(option)
        if is_plat("windows") and not option:enabled() then
            option:enable(false)
        else
            option:enable(true)
        end
    end)
end)

if get_config("has_libpthread") == false then
    add_requires("pthreads4w")
    add_packages("pthreads4w")
    add_defines("_CRT_SECURE_NO_WARNINGS")
end

target("lj_ringbuffer", function()
    set_kind("static")
    add_options("has_libpthread")
    add_files("src/library/*.c")
    add_packages("pthreads4w")
    add_includedirs("src/include/", {public = true })
end)

target("push_pull", function()
    set_kind("binary")
    add_options("has_libpthread")
    set_group("test")
    add_files("test/push_pull.c")
    add_deps("lj_ringbuffer")
end)

target("producer_consumer", function()
    set_kind("binary")
    add_options("has_libpthread")
    set_group("test")
    add_files("test/producer_consumer.c")
    add_deps("lj_ringbuffer")
end)
